#__*__coeding:utf-8__*__
#!/usr/share/python
'''
---------------------------------------------------------------- 
 版权所有。  
 
 文件名：
 文件功能描述： 
 author：
 时间：
--------------------------------------------------------------- 
'''

import datetime
import logging
from DB.dbbase import dbbase
from Base.tools import tools


class Setting:

    def __init__(self,period,execution_time,perform_number):
        self.period=period
        self.execution_time=execution_time
        self.perform_number=perform_number
        self.operating_time=tools.datetime_now_strfull()
        self.db=dbbase()

    def insert(self):
        values=(self.period,self.execution_time,self.perform_number,self.operating_time)
        sql = "INSERT INTO nginx_log_dispose_setting(period,execution_time,perform_number,operating_time) VALUES (%s,%s,%s,%s);"
        result=self.db.insertOne(sql,values)
        self.db.end(option='commit')
        self.db.dispose()
        return result

    def getperform_nmber(self):
        sql='SELECT perform_number FROM nginx_log_dispose_setting ORDER BY id DESC LIMIT 1'
        result=self.db.getOne(sql)
        self.db.end('commit')
        self.db.dispose()
        if result==None:
            return 0
        else:
            return result[0]

    def get_setting_limit(self):
        '''
        查询设置表最后一条数据
        :return: 数据列表
        '''
        SettingDataList = self.db.getOne(sql='select * from nginx_log_dispose_setting order by id DESC limit 1') #数据中周期值
        return SettingDataList